﻿namespace HRM.Update
{
    using DevExpress.LookAndFeel;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;

    public class XfmUpdateOffline : XtraForm
    {
        private ButtonEdit buttonEdit_0;
        private DefaultLookAndFeel defaultLookAndFeel_0;
        private IContainer icontainer_0 = null;
        private DevExpress.Utils.ImageCollection imageCollection_0;
        private LabelControl labelControl_0;
        private OpenFileDialog openFileDialog_0;
        private SimpleButton simpleButton_0;
        private SimpleButton simpleButton_1;

        public XfmUpdateOffline()
        {
            this.method_0();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer_0 != null))
            {
                this.icontainer_0.Dispose();
            }
            base.Dispose(disposing);
        }

        private void method_0()
        {
            this.icontainer_0 = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(XfmUpdateOffline));
            SerializableAppearanceObject appearance = new SerializableAppearanceObject();
            this.openFileDialog_0 = new OpenFileDialog();
            this.imageCollection_0 = new DevExpress.Utils.ImageCollection(this.icontainer_0);
            this.simpleButton_0 = new SimpleButton();
            this.buttonEdit_0 = new ButtonEdit();
            this.labelControl_0 = new LabelControl();
            this.defaultLookAndFeel_0 = new DefaultLookAndFeel(this.icontainer_0);
            this.simpleButton_1 = new SimpleButton();
            this.imageCollection_0.BeginInit();
            this.buttonEdit_0.Properties.BeginInit();
            base.SuspendLayout();
            this.openFileDialog_0.RestoreDirectory = true;
            this.openFileDialog_0.ShowReadOnly = true;
            this.imageCollection_0.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection1.ImageStream");
            this.imageCollection_0.Images.SetKeyName(0, "1285641621_folder_horizontal_open.png");
            this.imageCollection_0.Images.SetKeyName(1, "1285641966_agt_update_drivers.png");
            this.imageCollection_0.Images.SetKeyName(2, "Action_Exit.png");
            this.simpleButton_0.ImageIndex = 1;
            this.simpleButton_0.ImageList = this.imageCollection_0;
            this.simpleButton_0.Location = new Point(0x31, 0x3e);
            this.simpleButton_0.Name = "bttUpdate";
            this.simpleButton_0.Size = new Size(0x4b, 0x17);
            this.simpleButton_0.TabIndex = 3;
            this.simpleButton_0.Text = "Cập Nhật";
            this.simpleButton_0.Click += new EventHandler(this.simpleButton_0_Click);
            this.buttonEdit_0.Location = new Point(12, 0x22);
            this.buttonEdit_0.Name = "txtPath";
            this.buttonEdit_0.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Glyph, "", -1, true, true, false, ImageLocation.MiddleCenter, (Image) manager.GetObject("txtPath.Properties.Buttons"), new KeyShortcut(Keys.None), appearance, "", "Add", null, true) });
            this.buttonEdit_0.Properties.ReadOnly = true;
            this.buttonEdit_0.Properties.ButtonClick += new ButtonPressedEventHandler(this.method_1);
            this.buttonEdit_0.Size = new Size(0x179, 0x16);
            this.buttonEdit_0.TabIndex = 0;
            this.buttonEdit_0.TabStop = false;
            this.labelControl_0.Location = new Point(13, 13);
            this.labelControl_0.Name = "labelControl1";
            this.labelControl_0.Size = new Size(0x41, 13);
            this.labelControl_0.TabIndex = 4;
            this.labelControl_0.Text = "Chọn Mẩu Tin";
            this.defaultLookAndFeel_0.LookAndFeel.SkinName = "Blue";
            this.simpleButton_1.ImageIndex = 2;
            this.simpleButton_1.ImageList = this.imageCollection_0;
            this.simpleButton_1.Location = new Point(130, 0x3e);
            this.simpleButton_1.Name = "bttClose";
            this.simpleButton_1.Size = new Size(0x4b, 0x17);
            this.simpleButton_1.TabIndex = 5;
            this.simpleButton_1.Text = "Tho\x00e1t";
            this.simpleButton_1.Click += new EventHandler(this.simpleButton_1_Click);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x191, 0x5e);
            base.Controls.Add(this.simpleButton_1);
            base.Controls.Add(this.labelControl_0);
            base.Controls.Add(this.simpleButton_0);
            base.Controls.Add(this.buttonEdit_0);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "XfmUpdateOffline";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "Cập Nhập Th\x00f4ng Thường";
            this.imageCollection_0.EndInit();
            this.buttonEdit_0.Properties.EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void method_1(object sender, ButtonPressedEventArgs e)
        {
            if (!(((string) e.Button.Tag) != "Add"))
            {
                this.openFileDialog_0.Filter = "*.pf|*.*";
                this.openFileDialog_0.DefaultExt = "pf";
                this.openFileDialog_0.Title = "Cập nhật từ mẩu tin";
                this.openFileDialog_0.Multiselect = false;
                this.openFileDialog_0.ShowDialog();
                this.buttonEdit_0.Text = this.openFileDialog_0.FileName;
            }
        }

        private void method_2(bool bool_0)
        {
            base.Close();
            try
            {
                System.Diagnostics.Process.Start(Application.StartupPath + @"\HRM.HumanResource.exe");
                Environment.Exit(0);
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }

        private void simpleButton_0_Click(object sender, EventArgs e)
        {
            if (this.buttonEdit_0.Text == "")
            {
                XtraMessageBox.Show("Mẩu cập nhật chưa được chọn.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                this.buttonEdit_0.Focus();
            }
            else if (Path.GetExtension(this.buttonEdit_0.Text) == ".pf")
            {
                xfmOffProcess process = new xfmOffProcess(this.buttonEdit_0.Text);
                process.SuccessUpdate += new xfmOffProcess.SuccessEventHander(this.method_2);
                process.ShowDialog();
            }
            else
            {
                XtraMessageBox.Show("Phần mềm kh\x00f4ng thể nhận dạng mẩu cập nhật n\x00e0y.", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void simpleButton_1_Click(object sender, EventArgs e)
        {
            base.Close();
            try
            {
                System.Diagnostics.Process.Start(Application.StartupPath + @"\HRM.HumanResource.exe");
                Environment.Exit(0);
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
    }
}

